<?php
function mreadFile($path = NULL) {
    $data = array();  
    $file = fopen($path, "r") or exit("Unable to open file!");
    while (!feof($file)) {
        $data[] = fgets($file);
    }
    fclose($file);
    return $data;
}

function edit($contents = array()) {
    $path = realpath("SELECT * FROM works");
    $file = fopen($path, "w") or exit("Unable to open file!");
    foreach ($contents as $content) {
        if(!empty($content))
            $a = implode (";", $content);
        else
            $a = "";
        fwrite($file, $a.PHP_EOL);
    }
    fclose($file); 
}
